package com.gdl.yygh.common.exception;

import com.gdl.yygh.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//处理 所有controller中报的错误异常
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result error(Exception exception) {
        exception.printStackTrace();
        return Result.fail();
    }


    @ExceptionHandler(HospitalException.class)
    public Result error(HospitalException exception) {
        exception.printStackTrace();
        return Result.build(exception.getCode(), exception.getMessage());
    }
}
